﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace Business.Models
{
    public class NhanVien
    {
        [Key]
        public int IdNhanVien { get; set; }
        public string TenNhanVien { get; set; }
        [DataType(DataType.Password)]
        public string MatKhau { get; set; }
        [DataType(DataType.EmailAddress)]
        public string Email { get; set; }
        public DateTime NgayTao { get; set; }
        public bool HoatDong { get; set; }
        public string SoDienThoai { get; set; }
        public int IdTruongHoc { get; set; } 
        [ForeignKey("IdTruongHoc")]
        public virtual TruongHoc truongHoc { get; set; }
        public int? NguoiTao { get; set; }
        public byte LoaiNhanVien { get; set; }

    }

    public class NhanVienConfiguration : EntityTypeConfiguration<NhanVien>
    {

        public NhanVienConfiguration()
            : base()
        {
            HasKey(d => d.IdNhanVien);
            Property(d => d.IdNhanVien).
                HasColumnName("IdNhanVien").
                HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).
                IsRequired();
            HasKey(d => d.IdNhanVien);
            Property(d => d.IdTruongHoc).HasColumnName("TruongHoc");
            ToTable("NhanVien", "dbo");
        }
    }
}